package wqh.global;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by wqh on 2017/1/18.
 */
public class GlobalWaterAlarm {

    private static final Map<String, Object> maps = Collections.synchronizedMap(new HashMap<String,Object>());

    public static synchronized void addStatus(String idStr, Object value){
        maps.put(idStr,value);
    }

    public static synchronized void removeStatus(String idStr){
        maps.remove(idStr);
    }

    public static synchronized void clear(){
        maps.clear();
    }

    public static synchronized  Map<String ,Object> getMaps(){
        return maps;
    }

    public static synchronized Boolean getStatus(String idStr){
        if(!maps.isEmpty()){
            for(Map.Entry<String,Object> m : maps.entrySet()){
                if(m.getKey().equals(idStr)) {
                    return (Boolean)m.getValue();
                }
            }
        }
        return false;
    }

}
